#include <stdio.h>
#include <math.h>

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "yield_curve.h"

using namespace std;

typedef vector<double> DOUBLEVECTOR;

#define	NUM_OF_PERIODS_IN_INPUT_FILE	(10)

class CCreditCurve  
{
	DOUBLEVECTOR S;
	DOUBLEVECTOR Q;
	DOUBLEVECTOR CumQ;
	DOUBLEVECTOR H;

	YieldCurve yc;
	double R;
	long NumOfPeriodsInYear;

	inline double DF(long nPeriod);
	int GenerateQ();
	int GenerateCumQ();
	int GenerateH();
	double CumulativeQ(double time);

public:
	CCreditCurve();
	virtual ~CCreditCurve();

	int ReadCDSFile(string cdsfile);

	double GetRecoveryRate();
	void SetRecoveryRate(double RecoveryRate);
	long GetFrequency();
	void SetFrequency(long Frequency);

	double HazardRate(double time);
	double DiscountFactor(double time);
	double CreditSpread(double time);
	inline double SurvivalProbability(double time);
};
